package com.example.soss.util;


import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 接口防刷工具类
 */
public class RefreshLimitUtil {


    private static Cache<String, AtomicInteger> refreshLimit = CacheBuilder.newBuilder()
            .expireAfterWrite(5, TimeUnit.SECONDS).build();

    public static void set(String key, AtomicInteger atomicInteger) {
        refreshLimit.put(key, atomicInteger);
    }

    public static AtomicInteger get(String key) {
        return refreshLimit.getIfPresent(key);
    }
}
